/**
 * jqgrid toolbar 扩展插件
 */
(function ($, window, document, undefined) {
    'use strict';
    window.formatter = {};
 
    /**
     * 是否的状态, 例如 是(1)/否(0)
     */
    formatter.yesno = function (value, opts, rwdat, action) {
        var type_status = opts['colModel']['label'],
            display = rwdat.display,
            status = false,
            id = rwdat.id,
            url = '',
            style = '';

        switch (type_status) {
            case '菜单状态':
            case '节点状态':
                url = sy.url({
                    a: 'edit'
                });
                status = true;
                style = 'cursor: pointer';
                break;
        }

        return sy.fs(
            '<span class="{0} fa" style="{1}" data-id="{2}" data-display={3} data-url={4}  onclick="custom.statusEdit(this, {5})"></span>',
            value == 0 ? 'icon-disable' : 'icon-enable', style, id, display, url, status
        );
    };

    formatter.isObject = function (value, opts, rwdat, action) {
        return sy.fs(
            '<span class="{0} fa"></span>',
            value == 1 ? 'fa-complete' : 'fa-nocomplete'
        );
    }
    /**
     * 审核的状态, 例如待审核, 已审核
     */
    formatter.icon = function (value, opts, rwdat, action) {
        return sy.fs('<span class="el-tag {0}"></span>', value);
    };

    /**
     * 数字格式化只取整数
     */
    formatter.int = function (value, opts, rwdat, action) {
        var value = parseInt((value == null ? 0 : value));
        return sy.fs(
            '{0}',
            value == 0 ? '' : value
        );
    };


})(jQuery, window, document);